﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL.Object;

public partial class Controls_AdminHocKy : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lvHocKy.DataSource = HocKy.All();
            lvHocKy.DataBind();
        }
        
    }
    
  
    protected void lvHocKy_Sorting(object sender, ListViewSortEventArgs e)
    {

    }


    protected void lvHocKy_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        if (e.CommandName == "Insert")
        {
            TextBox txtFname = (TextBox)e.Item.FindControl("txtID");
            TextBox txtLname = (TextBox)e.Item.FindControl("txtName");
            //  TextBox txtCtype = (TextBox)e.Item.FindControl("txtCtype");
            // string insertCommand = "Insert into [Contacts] ([FirstName],[LastName],[ContactType]) Values('" + txtFname.Text + "', '" + txtLname.Text + "', '" + txtCtype.Text + "');";
            // SqlDataSource1.InsertCommand = insertCommand;
            Label3.Text = "0";
        }
        else if (e.CommandName == "Update")
        {
            TextBox txtFname = (TextBox)e.Item.FindControl("txtID");
            TextBox txtLname = (TextBox)e.Item.FindControl("txtName");
            //string updateCommand = "Update [Contacts] set [FirstName]='" + txtFname.Text + "', [LastName]='" + txtLname.Text + "', [ContactType]='" + txtCtype.Text + "' where Id=" + Convert.ToInt32(txtId.Text) + ";";
            // SqlDataSource1.UpdateCommand = updateCommand;
            Label3.Text = "1";
        }
        else if (e.CommandName == "Delete")
        {
            TextBox txtFname = (TextBox)e.Item.FindControl("txtID");

            // string deleteCommand = "delete from [Contacts] where Id=" + Convert.ToInt32(txtId.Text);
            // SqlDataSource1.DeleteCommand = deleteCommand;
            Label3.Text = "2";
        }
    }
   
}